package regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegMail {
    public static void main(String[] args) {
//标准邮箱验证正则
        String emailRegex = "^[A-Za-z0-9+_ .-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$";
        String[] emails = {
                "zhangsan@example.com",
                "11_si123@company.co.uk",
                "invalid-email@",
                "wangwu@subdomain.example.com"
        };
        Pattern pattern = Pattern.compile(emailRegex);
        for (String email : emails) {
            Matcher matcher = pattern.matcher(email);
            System.out.println(email + ": " + (matcher.matches() ? "有效" : "无效"));
        }
    }
}